/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.server.modules.sys.entity.material;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.server.common.persistence.TreeEntity;
import com.server.modules.sys.entity.Dict;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * 资料属性类别表Entity
 * @author 王磊
 * @version 2016-09-12
 */
public class MaterialType extends TreeEntity<MaterialType> {
	
	private static final long serialVersionUID = 1L;
	protected MaterialType parent;		// parent_id
	protected String name;		// 名称
	protected String type;		// 材料类型
	protected String keyName;		// 可选key
	protected String parentIds;		// parent_ids
	protected Integer sort;		// sort
	protected List<Dict> keyValues;		// 可选key对应字典表里面的value

	protected String chkvalue;   //存储复选款的值
	public String getChkvalue() {
		return chkvalue;
	}

	public void setChkvalue(String chkvalue) {
		this.chkvalue = chkvalue;
	}








	public List<Dict> getKeyValues() {
		return keyValues;
	}

	public void setKeyValues(List<Dict> keyValues) {
		this.keyValues = keyValues;
	}

	protected List<MaterialType> children=new ArrayList<>();

	public List<MaterialType> getChildren() {
		return children;
	}

	public void setChildren(List<MaterialType> children) {
		this.children = children;
	}

	public MaterialType() {
		super();
	}

	public MaterialType(String id){
		super(id);
	}

	@JsonBackReference
	public MaterialType getParent() {
		return parent;
	}

	public void setParent(MaterialType parent) {
		this.parent = parent;
	}
	
	@Length(min=1, max=255, message="名称长度必须介于 1 和 255 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Length(min=1, max=255, message="材料类型长度必须介于 1 和 255 之间")
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@Length(min=0, max=255, message="可选key长度必须介于 0 和 255 之间")
	public String getKeyName() {
		return keyName;
	}

	public void setKeyName(String keyName) {
		this.keyName = keyName;
	}
	
	@Length(min=1, max=2000, message="parent_ids长度必须介于 1 和 2000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@NotNull(message="sort不能为空")
	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}